#!/usr/bin/env python

import pg

print "Dark Voyage, Implemented in Python."

database = pg.DB(dbname='darkvoyage',host='localhost',user='darkvoyage',passwd='n8tg6JOr')

def Modifier(attribute):
    return ( int( attribute / 2 ) - 5 )

def PointCost(currentAttribute):
    pointCost = Modifier(currentAttribute)
    if pointCost == 0:
        pointCost = 1
    return pointCost

class Character:
    Name = "New Character"
    Owner = "None"
    Level = 1
    Race = "Human"
    Class = "Fighter"
    Points = 32
    Attribute = {}
    Attribute["Strength"] = 8
    Attribute["Dexterity"] = 8
    Attribute["Constitution"] = 8
    Attribute["Intelligence"] = 8
    Attribute["Wisdom"] = 8
    Attribute["Charisma"] = 8
    Save = {}
    Save["Fortitude"] = 0 + Modifier(Attribute["Constitution"])
    Save["Reflex"] = 0 + Modifier(Attribute["Reflex"])
    Save["Will"] = 0 + Modifier(Attribute["Wisdom"])
    HitPoints = 0 + Modifier(Attribute["Constitution"])
    ArmorClass = 10 + Modifier(Attribute["Dexterity"])
    Initiative = 0 + Modifier(Attribute["Dexterity"])
    BaseAttack = 0 + Modifier(Attribute["Strength"])
    Grapple = 0 + BaseAttack + Modifier(Attribute["Strength"])
    SpellResistance = 0
    
    def CharacterSheet(self):
        print "Character Name: %s" % (self.Name)
        print "Player Name: %s" % (self.Owner)
        print "Level %i, %i unspent points." % (self.Level,self.Points)
        print "STR: %i" % (self.Attribute["Strength"])
        print "DEX: %i" % (self.Attribute["Dexterity"])
        print "CON: %i" % (self.Attribute["Constitution"])
        print "INT: %i" % (self.Attribute["Intelligence"])
        print "WIS: %i" % (self.Attribute["Wisdom"])
        print "CHA: %i" % (self.Attribute["Charisma"])
    
    def ChangeName(self,newName):
        self.Name = newName
    
    def Register(self):
        contents = {}
        contents["name"] = self.Name
        database.insert("characters",contents)

Player = Character()

Player.CharacterSheet()
#Player.Register()
database.close
